package com.jx.lcs.product.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jx.lcs.product.dao.ProductDao;
import com.jx.lcs.product.entity.ProductInfo;
import com.tianyu.jty.common.persistence.HibernateDao;
import com.tianyu.jty.common.service.BaseService;

/** 
 * 产品Service
 * @author JiaYY 
 * @date 2015年7月2日
 */
@Service
@Transactional(readOnly=true)
public class ProductService extends BaseService<ProductInfo, String> {

	@Autowired
	private ProductDao productDao;

	@Override
	public HibernateDao<ProductInfo, String> getEntityDao() {
		return productDao;
	}
	
	/**
	 * 根据产品编码查询产品
	 * @param pcode
	 * @return
	 */
	public ProductInfo findByPCode(String pcode) {
		List<ProductInfo> list = productDao.findBy("pcode", pcode);
		ProductInfo product = null;
		if(list != null && list.size() > 0) {
			product = list.get(0);
		}
		return product;
	}
}
